<template>
	<view class="">
		<shop-list :dataList="dataList" :parameter="parameter"></shop-list>
		<template v-if="isComponent || pageNo > 1">
			<sww-load-more :params="{ init: true, loading: loading, len: dataList.length, loadMore: pageCount > pageNo }"></sww-load-more>
		</template>
	</view>
</template>

<script>
import { configMixin } from './configMixin.js';
import shopList from '@/pagecomponents/shopList/index.vue';
import { unigetLocation } from '@/utils/uniPromise.js';
export default {
	mixins: [configMixin],
	components: {
		shopList
	},
	watch: {
		templateItem: {
			handler(item) {
				if (item.code) {
					this.initList(item);
				}
			},
			immediate: true
		}
	},
	methods: {
		initPage(params) {
			this.$resPost('GetProductSupplierList', params).then(({ data }) => {
				this.dataList = data;
			});
		},

		initList() {
			this.parameter = {
				...this.templateItem.parameter
			};
			let params = {
				page_size: 12
			};
			if (this.parameter.status == 1) {
				unigetLocation(false)
					.then(res => {
						Object.assign(params, {
							coordinate_x: res.latitude,
							coordinate_y: res.longitude
						});
						this.initPage(params);
					})
					.catch(() => {
						this.parameter.status = 0;
						this.initPage(params);
					});
			} else {
				this.initPage(params);
			}
		}
	}
};
</script>

<style scoped lang="scss"></style>
